<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - mbi.info - multi_array/index_range.hpp</title>
  <link rel="stylesheet" type="text/css" href="../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../index.html">directory</a> - <a href="index.html">multi_array</a> - index_range.hpp</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>mbi.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2010-01-23</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">10</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">100.0 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">10</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : // Copyright 2002 The Trustees of Indiana University.
<span class="lineNum">       2 </span>                : 
<span class="lineNum">       3 </span>                : // Use, modification and distribution is subject to the Boost Software 
<span class="lineNum">       4 </span>                : // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
<span class="lineNum">       5 </span>                : // http://www.boost.org/LICENSE_1_0.txt)
<span class="lineNum">       6 </span>                : 
<span class="lineNum">       7 </span>                : //  Boost.MultiArray Library
<span class="lineNum">       8 </span>                : //  Authors: Ronald Garcia
<span class="lineNum">       9 </span>                : //           Jeremy Siek
<span class="lineNum">      10 </span>                : //           Andrew Lumsdaine
<span class="lineNum">      11 </span>                : //  See http://www.boost.org/libs/multi_array for documentation.
<span class="lineNum">      12 </span>                : 
<span class="lineNum">      13 </span>                : #ifndef BOOST_INDEX_RANGE_RG071801_HPP
<span class="lineNum">      14 </span>                : #define BOOST_INDEX_RANGE_RG071801_HPP
<span class="lineNum">      15 </span>                : 
<span class="lineNum">      16 </span>                : #include &lt;boost/config.hpp&gt;
<span class="lineNum">      17 </span>                : #include &lt;utility&gt;
<span class="lineNum">      18 </span>                : #include &lt;boost/limits.hpp&gt;
<span class="lineNum">      19 </span>                : 
<span class="lineNum">      20 </span>                : // For representing intervals, also with stride.
<span class="lineNum">      21 </span>                : // A degenerate range is a range with one element.
<span class="lineNum">      22 </span>                : 
<span class="lineNum">      23 </span>                : // Thanks to Doug Gregor for the really cool idea of using the
<span class="lineNum">      24 </span>                : // comparison operators to express various interval types!
<span class="lineNum">      25 </span>                : 
<span class="lineNum">      26 </span>                : // Internally, we represent the interval as half-open.
<span class="lineNum">      27 </span>                : 
<span class="lineNum">      28 </span>                : namespace boost {
<span class="lineNum">      29 </span>                : namespace detail {
<span class="lineNum">      30 </span>                : namespace multi_array {
<span class="lineNum">      31 </span>                : 
<span class="lineNum">      32 </span>                :   template &lt;typename Index,typename SizeType&gt;
<span class="lineNum">      33 </span>                :   class index_range {
<span class="lineNum">      34 </span>                :   public:
<span class="lineNum">      35 </span>                :     typedef Index index;
<span class="lineNum">      36 </span>                :     typedef SizeType size_type;
<span class="lineNum">      37 </span>                : 
<span class="lineNum">      38 </span>                :   private:
<span class="lineNum">      39 </span><span class="lineCov">              5 :     static index from_start()</span>
<span class="lineNum">      40 </span><span class="lineCov">              5 :       { return (std::numeric_limits&lt;index&gt;::min)(); }</span>
<span class="lineNum">      41 </span>                : 
<span class="lineNum">      42 </span><span class="lineCov">              5 :     static index to_end()</span>
<span class="lineNum">      43 </span><span class="lineCov">              5 :       { return (std::numeric_limits&lt;index&gt;::max)(); }</span>
<span class="lineNum">      44 </span>                : 
<span class="lineNum">      45 </span>                :   public:
<span class="lineNum">      46 </span>                : 
<span class="lineNum">      47 </span><span class="lineCov">              5 :     index_range()</span>
<span class="lineNum">      48 </span>                :     {
<span class="lineNum">      49 </span><span class="lineCov">              5 :       start_ = from_start();</span>
<span class="lineNum">      50 </span><span class="lineCov">              5 :       finish_ = to_end();</span>
<span class="lineNum">      51 </span><span class="lineCov">              5 :       stride_ = 1;</span>
<span class="lineNum">      52 </span><span class="lineCov">              5 :       degenerate_ = false;</span>
<span class="lineNum">      53 </span><span class="lineCov">              5 :     }</span>
<span class="lineNum">      54 </span>                : 
<span class="lineNum">      55 </span>                :     explicit index_range(index pos)
<span class="lineNum">      56 </span>                :     {
<span class="lineNum">      57 </span>                :       start_ = pos;
<span class="lineNum">      58 </span>                :       finish_ = pos+1;
<span class="lineNum">      59 </span>                :       stride_ = 1;
<span class="lineNum">      60 </span>                :       degenerate_ = true;
<span class="lineNum">      61 </span>                :     }
<span class="lineNum">      62 </span>                : 
<span class="lineNum">      63 </span>                :     explicit index_range(index start, index finish, index stride=1)
<span class="lineNum">      64 </span>                :       : start_(start), finish_(finish), stride_(stride),
<span class="lineNum">      65 </span>                :         degenerate_(false)
<span class="lineNum">      66 </span>                :     { }
<span class="lineNum">      67 </span>                : 
<span class="lineNum">      68 </span>                : 
<span class="lineNum">      69 </span>                :     // These are for chaining assignments to an index_range
<span class="lineNum">      70 </span>                :     index_range&amp; start(index s) {
<span class="lineNum">      71 </span>                :       start_ = s;
<span class="lineNum">      72 </span>                :       degenerate_ = false;
<span class="lineNum">      73 </span>                :       return *this;
<span class="lineNum">      74 </span>                :     }
<span class="lineNum">      75 </span>                : 
<span class="lineNum">      76 </span>                :     index_range&amp; finish(index f) {
<span class="lineNum">      77 </span>                :       finish_ = f;
<span class="lineNum">      78 </span>                :       degenerate_ = false;
<span class="lineNum">      79 </span>                :       return *this;
<span class="lineNum">      80 </span>                :     }
<span class="lineNum">      81 </span>                : 
<span class="lineNum">      82 </span>                :     index_range&amp; stride(index s) { stride_ = s; return *this; }
<span class="lineNum">      83 </span>                : 
<span class="lineNum">      84 </span>                :     index start() const
<span class="lineNum">      85 </span>                :     { 
<span class="lineNum">      86 </span>                :       return start_; 
<span class="lineNum">      87 </span>                :     }
<span class="lineNum">      88 </span>                : 
<span class="lineNum">      89 </span>                :     index get_start(index low_index_range = index_range::from_start()) const
<span class="lineNum">      90 </span>                :     { 
<span class="lineNum">      91 </span>                :       if (start_ == from_start())
<span class="lineNum">      92 </span>                :         return low_index_range;
<span class="lineNum">      93 </span>                :       return start_; 
<span class="lineNum">      94 </span>                :     }
<span class="lineNum">      95 </span>                : 
<span class="lineNum">      96 </span>                :     index finish() const
<span class="lineNum">      97 </span>                :     {
<span class="lineNum">      98 </span>                :       return finish_;
<span class="lineNum">      99 </span>                :     }
<span class="lineNum">     100 </span>                : 
<span class="lineNum">     101 </span>                :     index get_finish(index high_index_range = index_range::to_end()) const
<span class="lineNum">     102 </span>                :     {
<span class="lineNum">     103 </span>                :       if (finish_ == to_end())
<span class="lineNum">     104 </span>                :         return high_index_range;
<span class="lineNum">     105 </span>                :       return finish_;
<span class="lineNum">     106 </span>                :     }
<span class="lineNum">     107 </span>                : 
<span class="lineNum">     108 </span>                :     index stride() const { return stride_; }
<span class="lineNum">     109 </span>                : 
<span class="lineNum">     110 </span>                :     void set_index_range(index start, index finish, index stride=1)
<span class="lineNum">     111 </span>                :     {
<span class="lineNum">     112 </span>                :       start_ = start;
<span class="lineNum">     113 </span>                :       finish_ = finish;
<span class="lineNum">     114 </span>                :       stride_ = stride;
<span class="lineNum">     115 </span>                :     }
<span class="lineNum">     116 </span>                : 
<span class="lineNum">     117 </span>                :     static index_range all() 
<span class="lineNum">     118 </span>                :     { return index_range(from_start(), to_end(), 1); }
<span class="lineNum">     119 </span>                : 
<span class="lineNum">     120 </span>                :     bool is_degenerate() const { return degenerate_; }
<span class="lineNum">     121 </span>                : 
<span class="lineNum">     122 </span>                :     index_range operator-(index shift) const
<span class="lineNum">     123 </span>                :     { 
<span class="lineNum">     124 </span>                :       return index_range(start_ - shift, finish_ - shift, stride_); 
<span class="lineNum">     125 </span>                :     }
<span class="lineNum">     126 </span>                : 
<span class="lineNum">     127 </span>                :     index_range operator+(index shift) const
<span class="lineNum">     128 </span>                :     { 
<span class="lineNum">     129 </span>                :       return index_range(start_ + shift, finish_ + shift, stride_); 
<span class="lineNum">     130 </span>                :     }
<span class="lineNum">     131 </span>                : 
<span class="lineNum">     132 </span>                :     index operator[](unsigned i) const
<span class="lineNum">     133 </span>                :     {
<span class="lineNum">     134 </span>                :       return start_ + i * stride_;
<span class="lineNum">     135 </span>                :     }
<span class="lineNum">     136 </span>                : 
<span class="lineNum">     137 </span>                :     index operator()(unsigned i) const
<span class="lineNum">     138 </span>                :     {
<span class="lineNum">     139 </span>                :       return start_ + i * stride_;
<span class="lineNum">     140 </span>                :     }
<span class="lineNum">     141 </span>                : 
<span class="lineNum">     142 </span>                :     // add conversion to std::slice?
<span class="lineNum">     143 </span>                : 
<span class="lineNum">     144 </span>                :   public:
<span class="lineNum">     145 </span>                :     index start_, finish_, stride_;
<span class="lineNum">     146 </span>                :     bool degenerate_;
<span class="lineNum">     147 </span>                :   };
<span class="lineNum">     148 </span>                : 
<span class="lineNum">     149 </span>                :   // Express open and closed interval end-points using the comparison
<span class="lineNum">     150 </span>                :   // operators.
<span class="lineNum">     151 </span>                : 
<span class="lineNum">     152 </span>                :   // left closed
<span class="lineNum">     153 </span>                :   template &lt;typename Index, typename SizeType&gt;
<span class="lineNum">     154 </span>                :   inline index_range&lt;Index,SizeType&gt;
<span class="lineNum">     155 </span>                :   operator&lt;=(Index s, const index_range&lt;Index,SizeType&gt;&amp; r)
<span class="lineNum">     156 </span>                :   {
<span class="lineNum">     157 </span>                :     return index_range&lt;Index,SizeType&gt;(s, r.finish(), r.stride());
<span class="lineNum">     158 </span>                :   }
<span class="lineNum">     159 </span>                : 
<span class="lineNum">     160 </span>                :   // left open
<span class="lineNum">     161 </span>                :   template &lt;typename Index, typename SizeType&gt;
<span class="lineNum">     162 </span>                :   inline index_range&lt;Index,SizeType&gt;
<span class="lineNum">     163 </span>                :   operator&lt;(Index s, const index_range&lt;Index,SizeType&gt;&amp; r)
<span class="lineNum">     164 </span>                :   {
<span class="lineNum">     165 </span>                :     return index_range&lt;Index,SizeType&gt;(s + 1, r.finish(), r.stride());
<span class="lineNum">     166 </span>                :   }
<span class="lineNum">     167 </span>                : 
<span class="lineNum">     168 </span>                :   // right open
<span class="lineNum">     169 </span>                :   template &lt;typename Index, typename SizeType&gt;
<span class="lineNum">     170 </span>                :   inline index_range&lt;Index,SizeType&gt;
<span class="lineNum">     171 </span>                :   operator&lt;(const index_range&lt;Index,SizeType&gt;&amp; r, Index f)
<span class="lineNum">     172 </span>                :   {
<span class="lineNum">     173 </span>                :     return index_range&lt;Index,SizeType&gt;(r.start(), f, r.stride());
<span class="lineNum">     174 </span>                :   }
<span class="lineNum">     175 </span>                : 
<span class="lineNum">     176 </span>                :   // right closed
<span class="lineNum">     177 </span>                :   template &lt;typename Index, typename SizeType&gt;
<span class="lineNum">     178 </span>                :   inline index_range&lt;Index,SizeType&gt;
<span class="lineNum">     179 </span>                :   operator&lt;=(const index_range&lt;Index,SizeType&gt;&amp; r, Index f)
<span class="lineNum">     180 </span>                :   {
<span class="lineNum">     181 </span>                :     return index_range&lt;Index,SizeType&gt;(r.start(), f + 1, r.stride());
<span class="lineNum">     182 </span>                :   }
<span class="lineNum">     183 </span>                : 
<span class="lineNum">     184 </span>                : } // namespace multi_array
<span class="lineNum">     185 </span>                : } // namespace detail  
<span class="lineNum">     186 </span>                : } // namespace boost
<span class="lineNum">     187 </span>                : 
<span class="lineNum">     188 </span>                : #endif // BOOST_INDEX_RANGE_RG071801_HPP
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
